<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\CodeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '兑换码管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="code-index box box-primary">
    <div class="box-header">
        <!-- Check all button -->
        <!-- /.btn-group -->
        <a type="button" class="btn btn-default btn-sm" href="javascript:window.location.reload()"><i
                    class="fa fa-refresh"></i></a>
        <div class="visible-lg-block pull-right">
            <?php echo $this->render('_search', [
                'model' => $searchModel,
            ]); ?>
            <!-- /.btn-group -->
        </div>
        <!-- /.pull-right -->
    </div>
    <div class="box-body table-responsive no-padding">
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'layout' => "{items}\n{summary}\n{pager}",
            'columns' => [
                ['class' => 'yii\grid\SerialColumn'],
                'id',
                'goods_sn',
                'security_sn',
                'bar_code',
                'identity_code',
                [
                    'format' => 'raw',
                    'label' => '状态',
                    'value' => function ($m) {
                        return $m->status == 10 ? '未使用' : '已使用';
                    }

                ],
                [
                    'format' => 'raw',
                    'label' => '导出',
                    'value' => function ($m) {
                        return $m->is_receive == 0 ? '未导出' : '已导出';
                    }

                ],                // 'link',
                // 'created_at',
                // 'updated_at',

                ['class' => 'yii\grid\ActionColumn'],
            ],
        ]); ?>
    </div>
</div>
